package com.filter;

import com.pojo.SUser;
import com.service.IShowUserService;
import com.service.impl.ShowUserServiceImpl;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.List;

@WebFilter("/users.jsp")
public class TableFilter implements Filter {

    private IShowUserService service = new ShowUserServiceImpl();

    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {

        HttpServletRequest request = (HttpServletRequest) req;
        List<SUser> users = service.users();
        request.getSession().setAttribute("users",users);
        chain.doFilter(req, resp);



    }

    public void destroy() {
    }

    public void init(FilterConfig config) throws ServletException {

    }

}
